﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using KRS.Model;


namespace KRS.ViewModel.HouseInfoVMs
{
    public partial class HouseInfoVM : BaseCRUDVM<HouseInfo>
    {
        public List<FileAttachment> Attachments { get; set; }
        public HouseInfoVM()
        {
        }

        protected override void InitVM()
        {

        }

        public override void DoAdd()
        {           
            base.DoAdd();
        }

        public override void DoEdit(bool updateAllFields = false)
        {
            base.DoEdit(updateAllFields);
        }

        public override void DoDelete()
        {
            base.DoDelete();
        }

        public List<FileAttachment> GetFileAttachments(string houseID)
        {
            var photos = DC.Set<HousePhotos>().Where(it => it.HouseID.ToString().Equals(houseID)).ToList();
            List<Guid> fjIDs =photos.Select(it => it.FileId).ToList();
            var fileList = DC.Set<FileAttachment>().Where(it => fjIDs.Contains(it.ID)).ToList();
            return fileList;
        }
    }
}
